Lab 5 - Inventory

Introduction

The objective of this Lab is for you to demonstrate your understanding of multiple views, Navigation Controllers and List Views. We will build a multi-view application that permits the user to add, change or delete items in a list of inventory items with two String properties: a short and a long description.

You should have completed the study of iOS 14 Getting Started, modules 5 and 6: Creating iOS Apps with Multiple Screens, and Adding Behavior and Working With Data as well as How to make a view dismiss itself before attempting this assignment.

This assignment implements a simple CRUD (Create/Read/Update/Delete) application. Initially, the List view is empty. To add a new entry, the user taps on the Add button in the upper left, where they are taken to a second view with two input fields, the short and long description fields. The user clicks the Done button in the upper right to save the entry or the "Cancel" button to discard the entry and redisplay the list of items. Your app should allow the user to save items where both fields are empty without crashing.

To edit an existing entry, the user taps on the entry and is taken to an Edit dialog titled "Edit Item" where the user can modify either or both of the two fields, and taps Done to save or the "Cancel" button to cancel the edit session and return to the list of items.

To delete an existing entry, the user swipes right to left on the List view row and is shown a red button labeled "Delete". If pressed, the List view row is deleted from the table. This swiping action, if performed from far right to far left, automatically select the Delete function and deletes the item.

Adding an new item
Adding a new item
editing an existing item
Editing an existing item
deleting an existing item
Deleting an existing item
canceling either an add or an edit
Canceling out of either an add or an edit

In the animated examples above, the user launched the app, pressed the Add button in the upper right, adds a short and long description in a screen titled "Add New Item", then taps Save. The item is then saved and the app returns to displaying the List view, which is updated with the item just added at the bottom of the list. The items in the list are displayed in the List in the order in which they were originally added (in other words, do not sort).

Editing an item: in this example, the user then edited the previously added item, changed both fields, and clicked Save. The item is updated in place in the List view if Done is tapped. The act of tapping Cancel is then shown, which discards either an Add or an Edit dialog. Your app should also support tapping "Cancel" to cancel editing the item and dismissing an add or edit dialog and returning to the Inventory list.

Deleting an item: in this example, an occupied List row is swiped from right to left, and a red Delete button is presented. The user taps on the Delete button and the selected List cell is deleted.

Generate a Private Github Repository

  • Go to the Canvas Module for this assignment, click on the Clone This Repo link and follow the instructions to accept this assignment and receive a private repo.

Create Your initial Inventory project

  • Launch Xcode and create a new project. Select iOS App as the template and click Next. Set the product name to exactly “Inventory” and note the capitalization.

  • Make sure that "Include Unit Tests" and "Include UI Tests" and "Source Control" are checked.

Share Your Scheme

Share your scheme so your program can be compiled by our grading server:

  • Select iPhone 11 in the upper left of the Xcode screen

  • Go to Products→Schemes→Manage Schemes and locate the Inventory scheme. Place a checkmark in the Shared box on the far right and click Close to close the window.

Add Support Files and Commit Them to Github

To enable testing and grading of your lab, two files must be added to your Inventory project, the .github folder and the file InventoryUITestsCS3260.swift from https://github.com/tcowan/cs3260inventorytemplate.git. Refer to earlier lab writeups if you need a reminder for where these files should go and how to get them.

Do not in any way modify the files from the template repo. Doing so are grounds for giving you a failing grade for the semester.

Adding Your Remote Github Repo To Your Project

Adding a remote repo to your project tells Xcode where to send your project code when you request a "Push".

Build the User Interface

The Edit Item dialog is presented if the user taps on a List view row.

Both the Add New Item and the Edit Item views contain two objects: a single line textField and a multi-line textView. The identifier for the textField in the Add New Item dialog is addShortDescription, as shown below. You may see these two objects referred to as "title" and "subtitle" in the tests.

The accessibility label for the multi-line TextField is addLongDescription.

The Edit Item dialog uses editShortDescription and editLongDescription as its two accessibility labels.

Each field must have an accessibilityValue() modifier in addition to an accessibilityLabel() in order to pass all the tests.

Write your Inventory app

These are the general requirements for the Inventory app:

  • When the user taps the Add button, a dialog is pressented to add a single item with two attributes to the List. The two input fields should be empty upon entry. Tapping Save will save the data and always takes the user back to the List View by dismissing the Add New Item dialog.

  • Tapping the "Cancel" button always takes the user back to the List View without saving any changes in either Add New Item or Edit Item

  • When the user taps a row, a dialog is presented with the contents of that row for editing. Tapping "Save" updates the List for that entry.

  • Swiping from right to left in a List row presents a red Delete button, which when tapped will delete the current row in the table.

  • The title of the List View scene should be set to "Inventory".

Hint: I suggest that you create a struct for your short and long description strings, then create an array of these structures. I called my structure "struct Item { …​ } and my array of Items I called "items".

Test your application manually and verify its operation, then run the tests provided, one at a time. Remember, the tests provided are part of the requirements, so run them individually to make sure everything works. Push to your Github repo for grading.

Here Is How You Earn Points For This Assignment:

FEATURES POINTS

Required Features

App compiles with no errors

0

testVerifyLabels() passes - all the required labels and values are found

25

testAddItems() passes - new items can be added at the end of the List view

25

testAddEmptyItem() passes - a new item with an empty title or subtitle can be added at the end of the List view

25

testEditItem() passes - existing items can be edited and stored back into the List view in the original location

25

testDeleteItem() passes - an item in the List view can be deleted with a swipe to the left and tap motion

25

testCancelButtonDoesNotSave() passes - pressing the "Cancel" button cancels an Add or an Edit operation and returns to the List view without changing the List view

25

Total

150